home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / pcl_src.zoo / kcl-mods.txt < prev    next >
Text File  |  1991-12-20  |  9KB  |  225 lines

  1. If you have akcl version 604 or newer, do not make these patches.
  2.  
  3.  
  4. (1) Turbo closure patch
  5.  
  6. To make the turbo closure stuff work, make the following changes to KCL.
  7. These changes can also work for an IBCL.
  8.  
  9. The three patches in this file add two features (reflected in the
  10. value of *features*) to your KCL or IBCL:
  11.   a feature named :TURBO-CLOSURE which increases the speed of the
  12.      code generated by FUNCALLABLE-INSTANCE-DATA-1
  13.      (previous versions of the file kcl-mods.text had this feature only), 
  14. and
  15.   a feature named :TURBO-CLOSURE-ENV-SIZE which increases the speed
  16.      of the function FUNCALLABLE-INSTANCE-P.
  17.  
  18. (This file comprises two features rather than just one to allow the
  19. PCL system to be work in KCL systems that do not have this patch,
  20. or that have the old version of this patch.)
  21.  
  22.  
  23. The first of these patches changes the turbo_closure function to
  24. store the size of the environment in the turbo structure.
  25.  
  26. The second of patch fixes a garbage-collector bug in which
  27. the turbo structure was sometimes ignored, AND also adapts
  28. the garbage-collector to conform to the change made in the
  29. first patch.  The bug has been fixed in newer versions of
  30. AKCL, but it is still necessary to apply this patch, if the
  31. first and third patches are applied.
  32.  
  33. The third change pushes :turbo-closure and :turbo-closure-env-size
  34. on the *features* list so that PCL will know that turbo closures 
  35. are enabled.
  36.  
  37.  
  38. Note that these changes have to be made before PCL is compiled, and a
  39. PCL which is compiled in a KCL/IBCL with these changes can only be run
  40. in a KCL/IBCL with these changes.
  41.  
  42. (1-1) edit the function turbo_closure in the file kcl/c/cfun.c,
  43. change the lines
  44. ----------
  45. turbo_closure(fun)
  46. object fun;
  47. {
  48.         object l;
  49.         int n;
  50.  
  51.         for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  52.                 ;
  53.         fun->cc.cc_turbo = (object *)alloc_contblock(n*sizeof(object));
  54.         for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  55.                 fun->cc.cc_turbo[n] = l;
  56. }
  57. ----------
  58. to
  59. ----------
  60. turbo_closure(fun)
  61. object fun;
  62. {
  63.   object l,*block;
  64.   int n;
  65.  
  66.   if(fun->cc.cc_turbo==NULL)
  67.     {for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr);
  68.      block=(object *)alloc_contblock((1+n)*sizeof(object));
  69.      *block=make_fixnum(n);
  70.      fun->cc.cc_turbo = block+1; /* equivalent to &block[1] */
  71.      for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  72.        fun->cc.cc_turbo[n] = l;}
  73. }
  74. ----------
  75.  
  76.  
  77. (1-2) edit the function mark_object in the file kcl/c/gbc.c,
  78. Find the lines following case t_cclosure: in mark_object.
  79. If they look like the ones between the lines marked (KCL),
  80. make the first change, but if the look like the lines marked
  81. (AKCL), apply the second change instead, and if the file
  82. sgbc.c exists, apply the third change to it.
  83. (1-2-1) Change:
  84. (KCL)----------
  85.         case t_cclosure:
  86.                 mark_object(x->cc.cc_name);
  87.                 mark_object(x->cc.cc_env);
  88.                 mark_object(x->cc.cc_data);
  89.                 if (x->cc.cc_start == NULL)
  90.                         break;
  91.                 if (what_to_collect == t_contiguous) {
  92.                         if (get_mark_bit((int *)(x->cc.cc_start)))
  93.                                 break;
  94.                         mark_contblock(x->cc.cc_start, x->cc.cc_size);
  95.                         if (x->cc.cc_turbo != NULL) {
  96.                                 for (i = 0, y = x->cc.cc_env;
  97.                                      type_of(y) == t_cons;
  98.                                      i++, y = y->c.c_cdr);
  99.                                 mark_contblock((char *)(x->cc.cc_turbo),
  100.                                                i*sizeof(object));
  101.                         }
  102.                 }
  103.                 break;
  104. (KCL)----------
  105. to
  106. (KCL new)----------
  107.         case t_cclosure:
  108.                 mark_object(x->cc.cc_name);
  109.                 mark_object(x->cc.cc_env);
  110.                 mark_object(x->cc.cc_data);
  111.                 if (what_to_collect == t_contiguous)
  112.                         if (x->cc.cc_turbo != NULL) {
  113.                                 mark_contblock((char *)(x->cc.cc_turbo-1),
  114.                                                (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  115.                         }
  116.                 if (x->cc.cc_start == NULL)
  117.                         break;
  118.                 if (what_to_collect == t_contiguous) {
  119.                         if (get_mark_bit((int *)(x->cc.cc_start)))
  120.                                 break;
  121.                         mark_contblock(x->cc.cc_start, x->cc.cc_size);
  122.                 }
  123.                 break;
  124. (KCL new)----------
  125. (1-2-2) Or, Change:
  126. (AKCL)----------
  127.         case t_cclosure:
  128.                 mark_object(x->cc.cc_name);
  129.                 mark_object(x->cc.cc_env);
  130.                 mark_object(x->cc.cc_data);
  131.                 if (what_to_collect == t_contiguous) {
  132.                   if (x->cc.cc_turbo != NULL) {
  133.                     for (i = 0, y = x->cc.cc_env;
  134.                          type_of(y) == t_cons;
  135.                          i++, y = y->c.c_cdr);
  136.                     mark_contblock((char *)(x->cc.cc_turbo),
  137.                                                i*sizeof(object));
  138.                         }
  139.                 }
  140.                 break;
  141. (AKCL)----------
  142. To:
  143. (AKCL new)----------
  144.         case t_cclosure:
  145.                 mark_object(x->cc.cc_name);
  146.                 mark_object(x->cc.cc_env);
  147.                 mark_object(x->cc.cc_data);
  148.                 if (what_to_collect == t_contiguous) {
  149.                   if (x->cc.cc_turbo != NULL)
  150.                     mark_contblock((char *)(x->cc.cc_turbo-1),
  151.                                    (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  152.                 }
  153.                 break;
  154. (AKCL new)----------
  155. (1-2-3) In sgbc.c (if it exists), Change:
  156. (AKCL)----------
  157.         case t_cclosure:
  158.                 sgc_mark_object(x->cc.cc_name);
  159.                 sgc_mark_object(x->cc.cc_env);
  160.                 sgc_mark_object(x->cc.cc_data);
  161.                 if (what_to_collect == t_contiguous) {
  162.                   if (x->cc.cc_turbo != NULL) {
  163.                     for (i = 0, y = x->cc.cc_env;
  164.                          type_of(y) == t_cons;
  165.                          i++, y = y->c.c_cdr);
  166.                     mark_contblock((char *)(x->cc.cc_turbo),
  167.                                                i*sizeof(object));
  168.                         }
  169.                 }
  170.                 break;
  171. (AKCL)----------
  172. To:
  173. (AKCL new)----------
  174.         case t_cclosure:
  175.                 sgc_mark_object(x->cc.cc_name);
  176.                 sgc_mark_object(x->cc.cc_env);
  177.                 sgc_mark_object(x->cc.cc_data);
  178.                 if (what_to_collect == t_contiguous) {
  179.                   if (x->cc.cc_turbo != NULL)
  180.                     mark_contblock((char *)(x->cc.cc_turbo-1),
  181.                                    (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  182.                 }
  183.                 break;
  184. (AKCL new)----------
  185.  
  186.  
  187. (1-3) edit the function init_main in the file kcl/c/main.c,
  188. change the lines where setting the value of *features* to add a :turbo-closure
  189. and a :turbo-closure-env-size into the list in your KCL/IBCL.
  190.  
  191. For example, in Sun4(SunOS) version of IBCL
  192. changing the lines:
  193. ----------
  194.         make_special("*FEATURES*",
  195.                      make_cons(make_ordinary("SUN4"),
  196.                      make_cons(make_ordinary("SPARC"),
  197.                      make_cons(make_ordinary("IEEE-FLOATING-POINT"),
  198.                      make_cons(make_ordinary("UNIX"),
  199.                      make_cons(make_ordinary("BSD"),
  200.                      make_cons(make_ordinary("COMMON"),
  201.                      make_cons(make_ordinary("IBCL"), Cnil))))))));
  202. ----------
  203. to
  204. ----------
  205.         make_special("*FEATURES*",
  206.                      make_cons(make_ordinary("SUN4"),
  207.                      make_cons(make_ordinary("SPARC"),
  208.                      make_cons(make_ordinary("IEEE-FLOATING-POINT"),
  209.                      make_cons(make_ordinary("UNIX"),
  210.                      m